RUNNING CSOUND SCRIPTS IN SOUNDSHAPER (from 5.04)
=====================================

You can now run Csound scripts from within Soundshaper and combine them in patches with CDP processes.
 You must have Csound installed on your system (obviously). 
 You need to check "Run Csound Scripts" in Settings and re-save settings to your settings file (Soundshaper.cfg), then close and re-start the program. 
  The setting tells Soundshaper to find and set the path for CSOUND when Soundshaper starts.
  

There are four menu items in Tools | Run CSOUND Script:

 Synth - run a synthesis script (no infiles)
          Select a source cell for this, e.g. A_0
 With 1 input file
 With more than 1 input file
 Paulstretch - on 64-bit systems only (32-bit Csound doesn't have it)
          This is a stand-alone process built into Soundshaper, with parameters (which can be re-edited).


CSOUND with sound input(s)
--------------------------
For this, we need to route an infile from the patchgrid to the script, and copy the output back to the patchgrid.
For example:  ~A_0.wav --> CSOUND --> ~A_1.wav 

For the output, Soundshaper recognises the filenames csout.wav and test.wav.
You can put the former in the <CsOptions> section of a .csd file:
  <CsOptions>
  -o csout.wav -W
  <\CsOptions> 
In the older .orc/.sco format, an opcode like out or outs writes to test.wav by default. 
    

For the input(s), it is not practical for Soundshaper to analyse the Csound script to find its input files.
Instead, we need to identify these from a number of options:

 CSIN: the infile (e.g. ~A_0.wav) is copied to the file csin.wav and secondary inputs likewise to csin2,3,4,5.
        The script refers to these filenames (csin.wav [,csin2.wav, etc.]

 SOUNDIN: the infile(s) is/are copied to file(s) called soundin.1, soundin.2,...soundin.5.
          The opcode soundin often expects files of these names. This option is for such scripts.

 SOURCE: You choose infile1 and put it on the patchgrid, and optionally infiles 2,3... likewise.
          When the ADD INPUT selector pops up, you select either the appropriate patchgrid cells, or you can choose the files at that point.
          (Note that Infile2 is copied to the patchgrid, even if selected "externally" from a folder.)
          Infile1 in particular must be on a source cell (e.g. A_0).
  For example: 
           - the Csound script refers to the file "fox.wav". You select this for cell A_0 and choose SOURCE.
           - ~A_0.wav is copied to "fox.wav" in a separate subfolder (\~A_1 - as A_1 is the output cell).
           The script then runs with its expected sound. 
           However, there is an unexpected twist: the script refers to a filename, not a sound.
           So if you select, say, a drum sound for ~A_0.wav, this is copied to "fox.wav" and the script uses that.

 SAVED:  as SOURCE, but Infile1 uses a saved version of the infile cell.
          For example, the Infile cell is ~A_1.wav, which has been saved to "fox.wav", because that is the filename used in the script.
          - ~A_1.wav is copied to "fox.wav" in a separate subfolder (\~A_2 in the example).
          - as with SOURCE, this may or may not be the actual sound expected in the script.

 NONE:  a poor choice. You must have saved the files named in the script to your \TEMP folder, where Csound can find them.
         The .csd file (or .orc/.sco) is copied to the top level of \TEMP and run there (not in a sub-folder).
         This can be saved to a patch, but the infiles must be left in \TEMP. A sub-patch (patch run in a cell) is not possible.
          
Possible future choice (not implemented yet):
 ORIGINAL: to replace NONE. The expected files and the .csd file (or .orc/.sco) should be in their own folder.
         The whole folder is copied to a separate subfolder of \TEMP (e.g. \A_1 for that output cell).

Tests:
------
SYNTH has been tested as a patch on its own (in A_0) and also combined with CDP (in A_1). Cannot be a sub-patch, because this requires an infile.
CSIN, SOUNDIN and SOURCE have been tested in combination with CDP as a patch, a sub-patch (patch run in a cell) and even a sub-sub-patch.
SAVED tested as a patch.  NONE runs like SYNTH. 

Paulstretch tested as a patch combined with CDP, and as a sub-patch.

R.F. May '19 (minor revn May '23)

  
 
           
            


      





